import { http, Method } from "@/utils/request.js";

import api from "@/config/api.js";
import { md5 } from "@/utils/md5.js";

/**
 * 商家登录
 * @param username
 * @param password
 */

export function storeLogin(params) {
  return http.request({
    url: `/passport/login/userLogin`,
    method: Method.POST,
    header: { "content-type": "application/x-www-form-urlencoded" },
    data: {
      username: params.username,
      password: md5(params.password),
    },
  });
}

/**
 * 获取登录信息
 * @param {*} params
 * @returns
 */
export const getUserInfo = () => {
  return http.request({
    url: `/settings/storeSettings`,
    method: Method.GET,
  });
};

/**
 * 刷新token
 * @param {*} token
 * @returns
 */
export const refreshTokenFn = (token) => {
  return http.request({
    url: `/user/refresh/${token}`,
    method: Method.GET,
  });
};
export function loginOutAsync(){
	return http.request({
	  url: '/passport/login/logout',
	  method: "POST",
	  needToken: true,
	});
}